using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace org.synthful.Windows.Forms
{
    public partial class MultiButtonDialog : Form
    {
        public MultiButtonDialog()
        {
            InitializeComponent();
        }

        public MultiButtonDialog(params string[] _ButtonTxts)
        {
            this.InitializeComponent(_ButtonTxts);
        }

        private Button[] mkButtons(params string[] _ButtonTxts)
        {
            Button[] butts = new Button[_ButtonTxts.Length];

            for (int i = 0; i < _ButtonTxts.Length; i++)
            {
                butts[i] = new Button();
                butts[i].Text = _ButtonTxts[i];
                butts[i].Click += new EventHandler(whenClicked);
                butts[i].Dock = DockStyle.Fill;
                butts[i].Anchor =
                    (AnchorStyles)(
                        (AnchorStyles.Top | AnchorStyles.Left)
                        | AnchorStyles.Right
                    );
            }

            return butts;
        }

        private void whenClicked(object sender, EventArgs e)
        {
            if (sender == null)
                return;

            this.MultiButtonPanel.ClickedButton = sender as Button;
            this.Hide();
        }

        public Button Show(IWin32Window win, string title, string msg)
        {
            this.Text = title;
            this.MultiButtonPanel.TextDisplay.Text = msg;
            DialogResult r = this.ShowDialog(win);

            return this.MultiButtonPanel.ClickedButton;
        }
    }
}